<template>
  <div>
    <p>这是首页</p>

    <!-- 显示 Vuex 中获取的 count 状态 -->
    <h1>当前 count：{{ count }}</h1>

    <!-- 点击后累加 count 状态 -->
    <button @click="clickHandler">累加</button>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  computed: {
    count() {
      // 引入 Vuex 中的状态
      return this.$store.state.counter.count;
    },
  },
  async created() {
    const url = '/api/public/v1/home/swiperdata'
    const result = await axios.get(url);

    console.log(result);
  },
  methods: {
    clickHandler() {
      // 调用 Vuex mutations 改变状态
      this.$store.commit("counter/increase");
    },
  },
};
</script>

<style lang="scss" scoped>
</style>